
//数组的交集
function intersect(arr1,arr2){
    let _arr1=Array.from(new Set(arr1));
    let _arr2=Array.from(new Set(arr2));
    return _arr1.filter(item=>{
        return _arr2.includes(item);
    })
}

//定义数组
let arr1=[1,2,3,4,5]
let arr2=[1,4,5,6,89,9,0];
let res1=intersect(arr1,arr2);
console.log("数组交集：",res1);

//数组的并集
function union(arr1,arr2){
    let res=Array.from(new Set(arr1.concat(arr2)));
    return res;
}

let a=[1,2,4,5]
let b=[2,6]
let res2=union(a,b);
console.log("数组并集：",res2);
